﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmHost.aspx.cs" Inherits="WCrawler.frmHost" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            width: 407px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" language="javascript">
    function changeCheckState() {
        try {
            var frm = document.forms[0];
            var i = 0;
            for (i = 0; i < frm.length; i++) {
                if (frm.elements[i].id.indexOf('chkCheckItem') != -1) {
                    if (document.getElementById(frm.elements[i].id) != null) {
                        if (frm.elements[i].checked == false) {
                            frm.elements[i].checked = true;
                        } else {
                            frm.elements[i].checked = false;
                        }
                    }
                }
            }
        } catch (err) { }
    }
    </script>
    <asp:Button ID="btnUpdate" runat="server" Text="Update" 
        onclick="btnUpdate_Click" />
    <asp:Label ID="Label1" runat="server" Text="New Host"></asp:Label>
    <asp:TextBox ID="txtHostUrl" runat="server" Width="300px"></asp:TextBox>
    <asp:Button ID="btnAdd" runat="server" Text="Add" onclick="btnAdd_Click" />
    <asp:Label ID="lblMessage" runat="server"></asp:Label>
    <table style="width:100%;">
        <tr>
            <td class="style1" valign="top">
    <asp:GridView ID="gridViewHost" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="HostId" 
        DataSourceID="HostLinqDataSource" ForeColor="#333333" Width="100%" 
                    onselectedindexchanged="gridViewHost_SelectedIndexChanged">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                <HeaderTemplate>
                <asp:CheckBox ID="chkHead" runat="server"
                onclick="changeCheckState(this);" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chkCheckItem" Runat="server" />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Host" SortExpression="Host">
                <ItemTemplate>
                    <asp:HyperLink ID="hyperLinkHost" runat="server" NavigateUrl='<%#Eval("HostUrl") %>' Text='<%#Eval("HostName")%>'></asp:HyperLink>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtHostName" runat="server" Text='<%#Eval("HostName")%>'></asp:TextBox>
                    <asp:TextBox ID="txtHostUrl" runat="server" Text='<%#Eval("HostUrl") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Location" SortExpression="Location.LocationName">
                    <ItemTemplate>
                        <asp:Image ID="imgFlag" ImageUrl='<%#Eval("Location.FlagUrl")%>'  runat="server" />
                        <asp:Label ID="lblLocationName" runat="server" Text='<%#Eval("Location.LocationName")%>'></asp:Label>
                    </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="AlexaRank" HeaderText="AlexaRank" 
                SortExpression="AlexaRank" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
            </td>
            <td valign="top">
                <asp:DetailsView ID="DetailsViewHost" runat="server"  DataKeyNames="HostId"
                    DataSourceID="DetailViewHostLinqDataSource" Width="100%" BackColor="White" 
                    BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
                    ForeColor="Black" AutoGenerateRows="False" 
                    onitemdeleted="DetailsViewHost_ItemDeleted" 
                    oniteminserted="DetailsViewHost_ItemInserted">
                    <AlternatingRowStyle BackColor="White" />
                    <EditRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                    <Fields>
                        <asp:BoundField DataField="HostName" HeaderText="HostName" 
                            SortExpression="HostName" />
                        <asp:BoundField DataField="HostUrl" HeaderText="HostUrl" 
                            SortExpression="HostUrl" />
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                            ShowInsertButton="True" />
                    </Fields>
                    <FooterStyle BackColor="#CCCC99" />
                    <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                    <RowStyle BackColor="#F7F7DE" />
                </asp:DetailsView>
                <asp:LinqDataSource ID="DetailViewHostLinqDataSource" runat="server" 
                    ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EnableDelete="True" 
                    EnableInsert="True" EnableUpdate="True" EntityTypeName="" 
                    onselecting="DetailViewHostLinqDataSource_Selecting" TableName="Hosts">
                </asp:LinqDataSource>
            </td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    <asp:LinqDataSource ID="HostLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" 
        EnableDelete="True" EnableUpdate="True" EntityTypeName="" 
        TableName="Hosts" EnableInsert="True">
    </asp:LinqDataSource>
    <br />
</asp:Content>
